home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / cmdity / clicker.lha / Clicker / Source / sound.h < prev    next >
C/C++ Source or Header  |  1996-05-17  |  3KB  |  79 lines

  1. /*  File:         sound.h
  2.  *  Created:      20-10-95
  3.  *  Updated:      17-05-96
  4.  *  Version:      1.3
  5.  *  Project:      Clicker
  6.  *  Owner:        Jeroen Vermeulen
  7.  *  Requirements: KickStart V39+
  8.  *  Legal:        PD
  9.  *  Status:       Release
  10.  */
  11.  
  12. /* CreateSample():
  13.  * Open audio device and sample.  An IOAudio structure is returned unless either
  14.  * an error occurs or the error string was already non-NULL before the call.
  15.  * The structure is initialized for KeyClick(), ie. ready for a channel
  16.  * allocation request.
  17.  * ClickPrefs must also be properly initialized before KeyClick() can be called.
  18.  */
  19. struct IOAudio *CreateSample(STRPTR *const error);
  20.  
  21. /* DeleteSample():
  22.  * Destroy sample and free all resources allocated with it.  This function is
  23.  * overly robust so it can be used from within CreateSample() in case of an
  24.  * error.
  25.  */
  26. void DeleteSample(struct IOAudio *const soundrequest);
  27.  
  28.  
  29. /* KeyClick():
  30.  * Make key-click noise.  The soundrequest pointer is assumed to be valid and
  31.  * non-NULL, and point at a properly initialized IOAudio structure.
  32.  * The IOAudio structure must be set up for a channel allocation request; this
  33.  * is its default state to which it is also restored at the end of the function.
  34.  * This function accesses ClickPrefs; make sure it is set up properly (and set
  35.  * its "newsettings" flag for the initial call).
  36.  */
  37. void KeyClick(struct IOAudio *const soundrequest);
  38.  
  39.  
  40. /* SliderToHertz():
  41.  * Converts a prefs window slider position (between -5*12 and 4*12) to a
  42.  * frequency in Hertz, based on a twelve-tone octave centered at the 440 Hz A.
  43.  * This function is forced to take an unused Gadget parameter and to return LONG
  44.  * because it is passed to gadtools.library as a hook function.
  45.  */
  46. LONG SliderToHertz(const struct Gadget *const dum, const WORD sliderpos);
  47.  
  48.  
  49. /* HertzToPeriod():
  50.  * Converts human-readable pitch in Hertz to period length suitable for use by
  51.  * audio.device.  As a rule, HertzToPeriod(SliderToHertz(S)) is equivalent to
  52.  * SliderToPeriod(S).
  53.  */
  54. UWORD HertzToPeriod(const LONG Hertz);
  55.  
  56.  
  57. /* PeriodToHertz():
  58.  * Converts audio.device period length to human-readable pitch in Hertz.  This
  59.  * is the inverse of HertzToPeriod().  It needs to return LONG, so exact Hertz
  60.  * settings aren't possible.
  61.  */
  62. LONG PeriodToHertz(const UWORD period);
  63.  
  64.  
  65. /* SliderToPeriod():
  66.  * Converts a prefs window slider position (between 0 and 9*12) to a period
  67.  * length (in units of 279.365 nanoseconds) suitable for use by audio.device.
  68.  */
  69. UWORD SliderToPeriod(const WORD sliderpos);
  70.  
  71.  
  72. /* PeriodToSlider():
  73.  * Inverse of SliderToPeriod().  Takes a period length as an argument and
  74.  * computes the appropriate slider position (between -5*12 and 4*12).  This
  75.  * function can afford to be slow because it's only ever called when the prefs
  76.  * window pops up.
  77.  */
  78. WORD PeriodToSlider(const UWORD period);
  79.